package com.qiyeji.real_estate.service;

import com.qiyeji.real_estate.entity.project;
import com.qiyeji.real_estate.mapper.projectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

@Service
public class ProjectService {
    @Autowired
    projectMapper projectMapper;

    //获取全部项目的信息
    public List<project> getAllProject() {
        List<project> res = projectMapper.getAllProject();

        return res;
    }

    // 通过项目编号查询项目信息
    public project queryProjectByPCode(String pCode) {
        project res = projectMapper.selectByPrimaryKey(pCode);

        return res;
    }

    //通过客户编号查询项目信息
    public List<project> getProjectByCID(String cID) {
        List<project> res = projectMapper.getProjectByCID(cID);

        return res;
    }

    // 通过员工编号查询信息
    public List<project> getProjectBySCode(String sCode) {
        return projectMapper.getProjectBySCode(sCode);
    }

    //通过日期查询项目信息
    public List<project> getProjectByDate(String Date) {
        return projectMapper.getProjectByDate(Date);
    }

    //通过项目名称查询项目信息
    public List<project> getProjectByName(String Name) {
        return projectMapper.getProjectByName(Name);
    }

    //添加项目信息
    public Integer addProject(project record) {
        return projectMapper.insertSelective(record);
    }

    //删除项目信息
    public Integer deleteProject(String pCode) {
        return projectMapper.deleteByPrimaryKey(pCode);
    }

    //修改项目信息
    public Integer alterProject(project record) {
        return projectMapper.updateByPrimaryKeySelective(record);
    }

    //修改项目状态
    public Integer updateForComplete(String pCode) { return projectMapper.updateForComplete(pCode); }

    public CopyOnWriteArrayList<project> getAllProjectForExcel() { return projectMapper.getAllProjectForExcel(); }

    //通过项目负责表查询项目信息
    public List<project> getProjectBysCode(String sCode) { return projectMapper.getProjectBysCode(sCode); }
}
